<?php
//PingBuWang.Com
//Copyright (c) 2017~2099 http://www.pingbuwang.com All rights reserved.
namespace app\setting\model;

use think\Cache;
use mip\Paginationm;
use think\Db;
use think\Model;
use think\Controller;

class Setting extends Model
{
    public function doEdit( $arrSetting ){

        foreach ($arrSetting as $key => $val) {
            if(db("settings")->cache('c_setting_count_'.$key,60*60,'setting')->where( "`key` = '" . $key . "'")->count() == 0){
                db("settings")->insert(array('key'=>$key,'val'=>$val));
            }else{
                db("settings")->where( "`key` = '" . $key . "'")->update(array('val' => $val));
            }
        }
        Cache::clear('setting');

    }

    public function getList(){
        $settings = db('settings')->cache('c_setting_list',60*60,'setting')->select();
        return $settings;
    }

}